package com.zlk.algorithm.dataStructure.graph.topological;

// 拓扑排序模版（牛客）
// 邻接表建图（动态方式）
// 测试链接 : https://www.nowcoder.com/practice/88f7e156ca7d43a1a535f619cd3f495c
// 请同学们务必参考如下代码中关于输入、输出的处理
// 这是输入输出处理效率很高的写法
// 提交以下所有代码，把主类名改成Main，可以直接通过

import com.zlk.algorithm.bit.xor.Demo;

import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;

public class Code02_TopoSortDynamicNowcoder {


	public static int MAXN=10001;

	// 点数，边数
	// 接下来的m行，每行输入两个整数 Ui Vi 表示Ui 到vi之间有一条边
	public static int N,M;


	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StreamTokenizer in = new StreamTokenizer(br);
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		while (in.nextToken() != StreamTokenizer.TT_EOF) {
			N =(int)in.nval;
			in.nextToken();
			M = (int)in.nval;
			ArrayList<ArrayList<Integer>> list=new ArrayList<>();
			for (int i = 0; i <=N ; i++) {
				list.add(new ArrayList<>());
			}

			int[] inDegree = new int[N+1];
			for (int i = 1; i <= M; i++) {
				in.nextToken();
				int from = (int)in.nval;
				in.nextToken();
				int to = (int)in.nval;
				list.get(from).add(to);
				inDegree[to]++;
			}

			Queue<Integer> queue = new LinkedList<>();
			for (int i = 1 ;i <=N; i++) {
				if(inDegree[i]==0){
					queue.add(i);
				}
			}
			int index = 1;
			int[] ans = new int[N+1];
			while (!queue.isEmpty()){
				Integer poll = queue.poll();
				ans[index++]=poll;
				for (Integer next : list.get(poll)) {
					inDegree[next]--;
					if(inDegree[next]==0){
						queue.add(next);
					}
				}
			}
			if(index-1!=N){
				out.write(-1);
			}else{
				for (int i = 1; i < ans.length-1; i++) {
					out.print(ans[i] + " ");
				}
				out.println(ans[ans.length-1]);
			}
		}
		out.flush();
		out.close();
		br.close();
	}


}
